<div class="page-header">
    <h1><?php echo $this->titulo; ?></h1>
</div>

<form class="form-inline" role="form">
    <?php if($this->per_add){?>
    <div class="form-group">
        <a class="btn btn-success" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => '')); ?>"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Novo</a>
    </div>
    <?php } ?>
    <div class="form-group">
        <div class="input-group">
            <label class="sr-only" for="dtfiltro">Data</label>
            <input type="text" class="form-control" id="dtfiltro" name="dtfiltro" placeholder="Data" value="<?php echo $this->dtfiltro; ?>">
        </div>
    </div>    
    <div class="form-group">
        <div class="input-group">
            <label class="sr-only" for="dscfiltro">Nome</label>
            <input type="text" class="form-control" id="dscfiltro" name="dscfiltro" placeholder="Cliente" value="<?php echo $this->dscfiltro; ?>">
        </div>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-default">
            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
            Pesquisar
        </button>
    </div>    
</form>

<div class="table-responsive">
    <table id="tlist" class="table table-striped table-hover">
        <thead>
            <tr>
                <th>Data</th>
                <th>Cliente</th>
                <th>Valor</th>
                <th>Desconto</th>
                <th>Usuário</th>
                <th class="bc">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php 
            $VND_VLR = 0;
            $VND_VLRDSC = 0;
            foreach($this->result as $row) { 
                $VND_VLR += $row['VND_VLR'];
                $VND_VLRDSC += $row['VND_VLRDSC'];
            ?>
                <tr>
                    <td><?php echo Datetools::amd_dma($row['VND_DAT']).' '.Datetools::hora_hm($row['VND_HOR']); ?></td>
                    <td><?php echo $row['CLI_NOM']; ?></td>
                    <td><?php echo tools::float_to_money($row['VND_VLR']); ?></td>
                    <td><?php echo tools::float_to_money($row['VND_VLRDSC']); ?></td>
                    <td><?php echo $row['USU_NOM']; ?></td>
                    <td class="bc">
                        <?php if($this->per_edt){?><a class="btn btn-sm btn-primary" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['VND_ID'])); ?>"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span> Editar</a><?php }?>
                        <?php if($this->per_del && $row['VND_STA'] == 0){?><a class="btn btn-sm btn-danger" href="javascript:void(0);" onclick="list_delete_msg('<?php echo $this->controller; ?>', <?php echo $row['VND_ID'] ?>, $(this), '<?php echo $row['VND_NOM'] ?>');"><span class="glyphicon glyphicon-floppy-remove" aria-hidden="true"></span> Deletar</a><?php }?>
                    </td>
                </tr>
            <?php } ?>
            <?php if($VND_VLR > 0){ ?>
                <tr>
                    <td></td>
                    <td></td>
                    <td><strong><?php echo tools::float_to_money($VND_VLR);?></strong></td>
                    <td><strong><?php echo tools::float_to_money($VND_VLRDSC);?></strong></td>
                    <td></td>
                    <td></td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
 <?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
</div>
<script>dataPicker($('#dtfiltro'));</script>

